package hu.myai.model.db;

// Generated Jul 11, 2007 11:39:38 PM by Hibernate Tools 3.2.0.beta8

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;

/**
 * AxHistory generated by hbm2java
 */
@Entity
@Table(name = "ax_history", schema = "public", uniqueConstraints = { @UniqueConstraint(columnNames = { "date", "symbol" }) })
public class AxHistory implements java.io.Serializable {

	// Fields

	/**
	 * 
	 */
	private static final long serialVersionUID = 3627580524543429398L;

	private int id;

	private String symbol;

	private Date date;

	private double open;

	private double high;

	private double low;

	private double close;

	private Integer bookSell;

	private Integer bookBuy;

	private Double bookMaxBuy;

	private Integer bookMaxBuyVolume;

	private Double bookMinSell;

	private Integer bookMinSellVolume;

	private Integer volume;

	private AxHistory parent;

	private List<AxEstimation> axEstimations = new ArrayList<AxEstimation>(0);

	// Constructors

	/** default constructor */
	public AxHistory() {
	}

	/** minimal constructor */
	public AxHistory(int id, String symbol, Date date) {

		if (id > 0)
			this.id = id;
		this.symbol = symbol;
		this.date = date;
	}

	/** full constructor */
	public AxHistory(int id, String symbol, Date date, double open, double high, double low, double close,
			Integer bookSell, Integer bookBuy, Double bookMaxBuy, Integer bookMaxBuyVolume, Double bookMinSell,
			Integer bookMinSellVolume, Integer volume, AxHistory parent, List<AxEstimation> axEstimations) {
		this.id = id;
		this.symbol = symbol;
		this.date = date;
		this.open = open;
		this.high = high;
		this.low = low;
		this.close = close;
		this.bookSell = bookSell;
		this.bookBuy = bookBuy;
		this.bookMaxBuy = bookMaxBuy;
		this.bookMaxBuyVolume = bookMaxBuyVolume;
		this.bookMinSell = bookMinSell;
		this.bookMinSellVolume = bookMinSellVolume;
		this.volume = volume;
		this.parent = parent;
		this.axEstimations = axEstimations;
	}

	// Property accessors
	@javax.persistence.SequenceGenerator(name = "SEQ_GEN_HIST", sequenceName = "public.seq_history_id")
	// Property accessors
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ_GEN_HIST")
	@Column(name = "id", unique = true, nullable = false, insertable = true, updatable = true)
	public int getId() {
		return this.id;
	}

	public void setId(int id) {
		this.id = id;
	}

	@Column(name = "symbol", unique = false, nullable = false, insertable = true, updatable = true, length = 10)
	public String getSymbol() {
		return this.symbol;
	}

	public void setSymbol(String symbol) {
		this.symbol = symbol;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "date", unique = false, nullable = false, insertable = true, updatable = true, length = 4)
	public Date getDate() {
		return this.date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	@Column(name = "open", unique = false, nullable = true, insertable = true, updatable = true, precision = 8, scale = 4)
	public double getOpen() {
		return this.open;
	}

	public void setOpen(double open) {
		this.open = open;
	}

	@Column(name = "high", unique = false, nullable = true, insertable = true, updatable = true, precision = 8, scale = 4)
	public double getHigh() {
		return this.high;
	}

	public void setHigh(double high) {
		this.high = high;
	}

	@Column(name = "low", unique = false, nullable = true, insertable = true, updatable = true, precision = 8, scale = 4)
	public double getLow() {
		return this.low;
	}

	public void setLow(double low) {
		this.low = low;
	}

	@Column(name = "close", unique = false, nullable = true, insertable = true, updatable = true, precision = 8, scale = 4)
	public double getClose() {
		return this.close;
	}

	public void setClose(double close) {
		this.close = close;
	}

	@Column(name = "book_sell", unique = false, nullable = true, insertable = true, updatable = true)
	public Integer getBookSell() {
		return this.bookSell;
	}

	public void setBookSell(Integer bookSell) {
		this.bookSell = bookSell;
	}

	@Column(name = "book_buy", unique = false, nullable = true, insertable = true, updatable = true)
	public Integer getBookBuy() {
		return this.bookBuy;
	}

	public void setBookBuy(Integer bookBuy) {
		this.bookBuy = bookBuy;
	}

	@Column(name = "book_maxbuy", unique = false, nullable = true, insertable = true, updatable = true)
	public Double getBookMaxBuy() {
		return bookMaxBuy;
	}

	public void setBookMaxBuy(Double bookMaxBuy) {
		this.bookMaxBuy = bookMaxBuy;
	}

	@Column(name = "book_maxbuy_volume", unique = false, nullable = true, insertable = true, updatable = true)
	public Integer getBookMaxBuyVolume() {
		return bookMaxBuyVolume;
	}

	public void setBookMaxBuyVolume(Integer bookMaxBuyVolume) {
		this.bookMaxBuyVolume = bookMaxBuyVolume;
	}

	@Column(name = "book_minsell", unique = false, nullable = true, insertable = true, updatable = true)
	public Double getBookMinSell() {
		return bookMinSell;
	}

	public void setBookMinSell(Double bookMinSell) {
		this.bookMinSell = bookMinSell;
	}

	@Column(name = "book_minsell_volume", unique = false, nullable = true, insertable = true, updatable = true)
	public Integer getBookMinSellVolume() {
		return bookMinSellVolume;
	}

	public void setBookMinSellVolume(Integer bookMinSellVolume) {
		this.bookMinSellVolume = bookMinSellVolume;
	}

	@Column(name = "volume", unique = false, nullable = true, insertable = true, updatable = true)
	public Integer getVolume() {
		return this.volume;
	}

	public void setVolume(Integer volume) {
		this.volume = volume;
	}

	@OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.LAZY, mappedBy = "axHistory")
	public List<AxEstimation> getAxEstimations() {
		return this.axEstimations;
	}

	public void setAxEstimations(List<AxEstimation> axEstimations) {
		this.axEstimations = axEstimations;
	}

	@OneToOne(cascade = {}, fetch = FetchType.LAZY)
	@JoinColumn(name = "parent", unique = false, nullable = true, insertable = true, updatable = true)
	public AxHistory getParent() {
		return parent;
	}

	public void setParent(AxHistory parent) {
		this.parent = parent;
	}

	public boolean equals(AxHistory history) {
		return this.symbol == history.symbol && this.date == history.date;
	}

	@Override
	public String toString() {
		StringBuffer retValue = new StringBuffer();
		retValue.append("id: ").append(this.id).append("; ");
		retValue.append("symbol: ").append(this.symbol).append("; ");
		retValue.append("date: ").append(this.date).append("; ");
		retValue.append("open: ").append(this.open).append("; ");
		retValue.append("high: ").append(this.high).append("; ");
		retValue.append("low: ").append(this.low).append("; ");
		retValue.append("close: ").append(this.close).append("; ");
		// retValue.append("bookSell: ").append(this.bookSell).append("; ");
		// retValue.append("bookBuy: ").append(this.bookBuy).append("; ");
		retValue.append("bookMaxBuy: ").append(this.bookMaxBuy).append("; ");
		// retValue.append("bookMaxBuyVolume: ").append(this.bookMaxBuyVolume).append("; ");
		retValue.append("bookMinSell: ").append(this.bookMinSell).append("; ");
		// retValue.append("bookMinSellVolume: ").append(this.bookMinSellVolume).append("; ");
		retValue.append("volume: ").append(this.volume).append("; ");

		return retValue.toString();
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((axEstimations == null) ? 0 : axEstimations.hashCode());
		result = prime * result + ((bookBuy == null) ? 0 : bookBuy.hashCode());
		result = prime * result + ((bookMaxBuy == null) ? 0 : bookMaxBuy.hashCode());
		result = prime * result + ((bookMaxBuyVolume == null) ? 0 : bookMaxBuyVolume.hashCode());
		result = prime * result + ((bookMinSell == null) ? 0 : bookMinSell.hashCode());
		result = prime * result + ((bookMinSellVolume == null) ? 0 : bookMinSellVolume.hashCode());
		result = prime * result + ((bookSell == null) ? 0 : bookSell.hashCode());
		long temp;
		temp = Double.doubleToLongBits(close);
		result = prime * result + (int) (temp ^ (temp >>> 32));
		result = prime * result + ((date == null) ? 0 : date.hashCode());
		temp = Double.doubleToLongBits(high);
		result = prime * result + (int) (temp ^ (temp >>> 32));
		result = prime * result + id;
		temp = Double.doubleToLongBits(low);
		result = prime * result + (int) (temp ^ (temp >>> 32));
		temp = Double.doubleToLongBits(open);
		result = prime * result + (int) (temp ^ (temp >>> 32));
		result = prime * result + ((parent == null) ? 0 : parent.hashCode());
		result = prime * result + ((symbol == null) ? 0 : symbol.hashCode());
		result = prime * result + ((volume == null) ? 0 : volume.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		AxHistory other = (AxHistory) obj;
		if (axEstimations == null) {
			if (other.axEstimations != null)
				return false;
		} else if (!axEstimations.equals(other.axEstimations))
			return false;
		if (bookBuy == null) {
			if (other.bookBuy != null)
				return false;
		} else if (!bookBuy.equals(other.bookBuy))
			return false;
		if (bookMaxBuy == null) {
			if (other.bookMaxBuy != null)
				return false;
		} else if (!bookMaxBuy.equals(other.bookMaxBuy))
			return false;
		if (bookMaxBuyVolume == null) {
			if (other.bookMaxBuyVolume != null)
				return false;
		} else if (!bookMaxBuyVolume.equals(other.bookMaxBuyVolume))
			return false;
		if (bookMinSell == null) {
			if (other.bookMinSell != null)
				return false;
		} else if (!bookMinSell.equals(other.bookMinSell))
			return false;
		if (bookMinSellVolume == null) {
			if (other.bookMinSellVolume != null)
				return false;
		} else if (!bookMinSellVolume.equals(other.bookMinSellVolume))
			return false;
		if (bookSell == null) {
			if (other.bookSell != null)
				return false;
		} else if (!bookSell.equals(other.bookSell))
			return false;
		if (Double.doubleToLongBits(close) != Double.doubleToLongBits(other.close))
			return false;
		if (date == null) {
			if (other.date != null)
				return false;
		} else if (!date.equals(other.date))
			return false;
		if (Double.doubleToLongBits(high) != Double.doubleToLongBits(other.high))
			return false;
		if (id != other.id)
			return false;
		if (Double.doubleToLongBits(low) != Double.doubleToLongBits(other.low))
			return false;
		if (Double.doubleToLongBits(open) != Double.doubleToLongBits(other.open))
			return false;
		if (parent == null) {
			if (other.parent != null)
				return false;
		} else if (!parent.equals(other.parent))
			return false;
		if (symbol == null) {
			if (other.symbol != null)
				return false;
		} else if (!symbol.equals(other.symbol))
			return false;
		if (volume == null) {
			if (other.volume != null)
				return false;
		} else if (!volume.equals(other.volume))
			return false;
		return true;
	}

}
